<template>
	<view class="evaluate mt-20 b-24">
		<view class="f ai-c jc-s-b pt-32 ph-32">
			<view class="fs-36 fw-600 text-color4">客户评价</view>
			<view class="f ai-c" @click="toMore">
				<view class="fs-24 text-color3">查看全部</view>
				<u-icon name="arrow-right" color="#999999" size="10"></u-icon>
			</view>
		</view>
		<view class="w-f b-24" v-if="list.length>0">
			<view class="pv-32 ph-32">
				<view class="mb-30" v-for="item in list">
					<view class="f ai-c">
						<u-avatar :src="item.userAvatar" size="80rpx"></u-avatar>
						<view class="ml-20">
							<view class="fs-32 fw-500 text-color4">{{item.userNickname}}</view>
							<view class="f ai-c mt-2">
								<view class="fs-24 text-color3">商品评分{{item.scores}}</view>
								<view class="f">
									<image :src="starSelect" class="w-24 h-24 mr-8" v-for="(item2, index2) in item.scores"
										:key="index2"></image>
										<image :src="star" class="w-24 h-24 mr-8" v-for="(item2, index2) in 5-item.scores"
											:key="index2"></image>
								</view>
								<view class="fs-24 text-color3 ml-20">{{item.createTime}}</view>
							</view>
						</view>
					</view>
					<view class="mt-24 fs-26 text-color4">{{item.content}}</view>
					<view class="f fc-w">
						<image :src="item2" class="w-152 h-152 b-4 mr-12 mt-12" v-for="(item2,index2) in item.picUrls"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script setup lang="ts">
	import { ref,toRefs,watch,getCurrentInstance} from 'vue';
	import { onLoad } from '@dcloudio/uni-app';
	import { commentPage } from '@/services/api/shop/index'
	import star from '@/static/index/star.png';
	import starSelect from '@/static/index/star-select.png';
	const props = defineProps({
		id: {
			type: String,
		},
	});
	const { proxy } = getCurrentInstance();
	const { id } = toRefs(props);
	const pageNo=ref(1)
	const list=ref([])
	const storeId=ref('')
	watch(
	    () => [id?.value],
	    () => {
	        storeId.value = id?.value;
	       getEvaluate()
	    }
	);
	async function getEvaluate() {
		let data = {
			type: 0,
			pageNo: pageNo.value,
			pageSize: 10,
			storeId: storeId.value
		}
		const res = await commentPage(data)
		res.data.list.forEach((item: any) => {
		    item.createTime = proxy.$moment(item.createTime).format('YYYY.MM.DD HH:mm:ss');
		});
		list.value=res.data.list
	}
	function toMore(){
		uni.navigateTo({
			url:'/pages_shop/commentShopList?id='+storeId.value
		})
	}
	function getNum(index,num){
		
		console.log(index,num)
		return index<Number(num)-1
	}
</script>
<style lang="scss" scoped>
	.evaluate {
		background: #fff;

		.btn {
			background: #faf5e6;
		}
	}
</style>